package http

import (
	"gateway"
	"gateway/core"
)

type Route struct {
	Api            core.Api
	GatewayContext core.GatewayContext
}

func NewRoute() Route {
	return Route{}
}

func (route Route) Route() {

	//url := route.GatewayContext.Request.URL
	//service := strings.Split(url,"/")[1]
	/**
	获取负载均衡列表
	*/

}

func (route Route) Pre() core.Response {

	//黑名单

	pipemap := core.GetInstance().Pipes
	blackList := pipemap[gateway.Pipe_BlackList]
	blackList.Call(route.GatewayContext)
	response := route.GatewayContext.Response
	if response.Success != gateway.Success_Code {
		return response
	}
	//token校验
	token := pipemap[gateway.Pipe_Token]
	token.Call(route.GatewayContext)
	response = route.GatewayContext.Response
	if response.Success != gateway.Success_Code {
		return response
	}
	//限流

	//metric统计
	return response
}

func (route Route) Post() {

}

func (route Route) Error() {

}
